#!/usr/bin/env node

// const http = require('http');
// http.createServer((req,res)=>{
//     res.end('hello world!');
// }).listen(8080);

// 两个终端
// 执行文件  ./02-hello-world-server.js
// curl http://localhost:8080
// curl -i http://localhost:8080 查看响应报文
// curl -v http://localhost:8080 拆开查看请求、响应报文

// 为16-03-post准备的
const http = require('http');
const log = console.log;
http.createServer((req,res)=>{
    log(`${req.method} ${req.url} HTTP/${req.httpVersion}`);
    log(req.headers);
    log();
    req.pipe(process.stdout);

    res.end('hello world!');
}).listen(8080);